<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/denglu.css" />
    <link rel="stylesheet" type="text/css" href="css/zhuce.css" />
</head>

<body>
    <div id="top">
        <img src="img/images/pic.png">
    </div>
    <div id="hoder">
        <div id="hoder-con">
            <img src="img/images/logo.png"><br>
            <span class="one">注册&nbsp;&nbsp;&nbsp;</span>
            <span class="two">&nbsp;&nbsp;<a href="http://10.35.162.123/jinlixiangmu/denglu.html">登录</a> &nbsp;&nbsp;</span>
            <span class="three"><img src="img/images/images/登录_03.png" ></span>


            <p>

                <input type="text" id="username" placeholder="请输入账号">
            </p>
            <p>

                <input type="password" id="password" placeholder="请输入密码">
            </p>
            <p>
                <!-- <label for="repassword">确认密码</label> -->
                <input type="password" id="repassword" placeholder="确认密码">
            </p>
            <p>
                <button id="register">注册</button>
            </p>
        </div>
    </div>
</body>

</html>
<script src='jquery.min.js'></script>
<script>
    $("#register").click(function() {
        let username = $("#username").val()
        let password = $("#password").val()
        let repassword = $("#repassword").val()

        if ((username && password && repassword) && (password === repassword)) {
            $.ajax({
                url: "http://10.35.162.123:8080/zhuce",
                data: {
                    username: username,
                    password: password
                },
                success(data) {
                    if (data === "success") {
                        alert("注册成功!");
                        location.href = "http://10.35.162.123/jinlixiangmu/denglu.html"
                    }
                    if (data === "exist") {
                        alert("已存在的用户名")
                    }
                }
            })
        } else {
            alert("请正确输入")
        }
    })
</script>